//
//  MyPmCell.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/4/20.
//  Copyright © 2016年 game. All rights reserved.
//

#import "MyPmCell.h"
#import "NSString+HtmlCharact.h"
#import "UILabel+BoundRect.h"
#import "YYText.h"
#import "YYLabel.h"
#import "NSString+HtmlCharact.h"
#import "NSString+DealTheMessage.h"
#import "MBButtonWithFontAdapter.h"
#import "MBLabelWithFontAdapter.h"
#import "MBTextFieldWithFontAdapter.h"
#import "MBTextViewWithFontAdapter.h"
#import "UIButton+WebCache.h"
@interface MyPmCell ()
@property (weak, nonatomic) IBOutlet UIButton *headImage;
@property (weak, nonatomic) IBOutlet MBButtonWithFontAdapter *name;
@property (weak, nonatomic) IBOutlet MBLabelWithFontAdapter *time;
@property (weak, nonatomic) IBOutlet YYLabel *content;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contenthight;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headHeight;
@property (weak, nonatomic) IBOutlet UILabel *footView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *footHight;

@end

@implementation MyPmCell

- (void)awakeFromNib {
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    self.selectionStyle = 0;
    self.footView.backgroundColor = tabPlainBackColor;
    self.footHight.constant = SCREEN_HEIGHT*0.03;
    
    self.headHeight.constant = SCREEN_WIDTH*0.07;
    self.headWidth.constant = self.headHeight.constant;
    radius(self.headImage, self.headHeight.constant/2);
    
    self.content.textVerticalAlignment = YYTextVerticalAlignmentCenter;
    self.content.numberOfLines = 0;
    self.content.font = font(SCREEN_WIDTH*0.043);}

-(void)setModel:(MyPmListModel *)model{
    _model = model;

    [self.headImage sd_setImageWithURL:[NSURL URLWithString:_model.avatar] forState:UIControlStateNormal];
    [self.name setTitle:_model.msgfrom forState:UIControlStateNormal];
    self.time.text = [_model.vdateline filterresult];
    
    
    NSMutableAttributedString* mas = [[_model.message filterresult] dealTheMessage];
    self.content.attributedText = mas;
    CGSize size = CGSizeMake(SCREEN_WIDTH-24, CGFLOAT_MAX);
    YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:mas];
    
    self.contenthight.constant = layout.textBoundingSize.height;
    self.height = layout.textBoundingSize.height+SCREEN_HEIGHT*0.15;
    self.Touid = _model.touid;
}

- (IBAction)spaceClick:(UIButton *)sender {
    
    if ([self.deleget respondsToSelector:@selector(ToSpaceWhithUid:)]) {
        
        [self.deleget ToSpaceWhithUid:_model.msgfromid];
    }
}
@end